home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / XSPAWN.ARJ / MP.ASM < prev    next >
Assembly Source File  |  1991-05-04  |  5KB  |  116 lines

  1. ;
  2. ; (C) Copyright 1990 Whitney Software, Inc.
  3. ;            All Rights Reserved
  4. ;
  5. ; Source for MP.COM.  Displays a list of the interrupt vectors that point to
  6. ; interrupt handlers in the parent process.
  7. ;
  8.  
  9. arena           struc                           ; arena header
  10. sig             db      0                       ; 'M' or 'Z' if last block
  11. own             dw      0                       ; PSP of owner or 0 if free
  12. siz             dw      0                       ; size not including header
  13. arena           ends
  14.  
  15. _TEXT           SEGMENT word public 'CODE'
  16.  
  17.                 ORG     100h
  18.  
  19.                 ASSUME  cs:_TEXT
  20.                 ASSUME  ds:_TEXT
  21.                 ASSUME  es:_TEXT
  22.                 ASSUME  ss:_TEXT
  23.  
  24. begin:          mov     cx,36                   ; length
  25.                 mov     dx,offset msg1          ; message 1
  26.                 call    printm                  ; print message
  27.                 mov     di,ds:[16h]             ; parent's PSP segment
  28.                 dec     di
  29.                 mov     es,di                   ; parent's arena header
  30.                 inc     di                      ; parent's PSP segment
  31.                 mov     dx,di
  32.                 add     dx,es:[siz]             ; next block
  33.                 xor     cx,cx                   ; interrupt number
  34.  
  35. ; top of loop for each interrupt (0-FF)
  36.  
  37. display1:       mov     ah,35h                  ; get interrupt vector
  38.                 mov     al,cl                   ; interrupt number
  39.                 int     21h
  40.                 mov     ax,es                   ; vector segment
  41.                 push    cx                      ; interrupt number
  42.                 mov     cl,4                    ; shift count
  43.                 shr     bx,cl                   ; divide vector offset by 16
  44.                 pop     cx                      ; interrupt number
  45.                 add     ax,bx                   ; AX = segment + offset / 16
  46.                 cmp     ax,di                   ; vector < parent's PSP?
  47.                 jb      display2                ; yes, jump
  48.                 cmp     ax,dx                   ; vector >= next block?
  49.                 jae     display2                ; yes, jump
  50.                 push    cx                      ; interrupt number
  51.                 push    dx                      ; next block
  52.                 mov     ax,cx                   ; integer = interrupt number
  53.                 call    printi                  ; print integer
  54.                 pop     dx                      ; next block
  55.                 pop     cx                      ; interrupt number
  56.  
  57. display2:       inc     cx                      ; next interrupt
  58.                 or      ch,ch                   ; is interrupt number <= 255?
  59.                 jz      display1                ; yes, jump
  60.                 mov     cx,2                    ; length
  61.                 mov     dx,offset msg2          ; message 2 (CR/LF)
  62.                 call    printm                  ; print message
  63.                 mov     ax,4C00h                ; terminate with 0 return code
  64.                 int     21h
  65.  
  66. printm          PROC    near
  67.  
  68. ; Call with:    CX = message length
  69. ;               DX = message
  70.  
  71.                 mov     ah,40h                  ; write file or device
  72.                 mov     bx,1                    ; standard output device handle
  73.                 int     21h
  74.                 ret
  75.  
  76. printm          ENDP
  77.  
  78. printi          PROC    near
  79.  
  80. ; Call with:    AX = integer
  81.  
  82.                 mov     cl,16                   ; radix equals 16
  83.                 mov     si,offset buffer + 2    ; end of buffer
  84.                 push    si
  85.  
  86. printi1:        div     cl                      ; divide integer by 16
  87.                 add     ah,'0'                  ; convert remainder to ASCII
  88.                 cmp     ah,'9'                  ; is it 0-9?
  89.                 jle     printi2                 ; yes, jump
  90.                 add     ah,'A'-'9'-1            ; it is A-F, correct
  91.  
  92. printi2:        dec     si                      ; back up through buffer
  93.                 mov     [si],ah                 ; store character in buffer
  94.                 xor     ah,ah
  95.                 or      al,al                   ; is integer 0 yet?
  96.                 jnz     printi1                 ; no, get next character
  97.  
  98.                 pop     cx                      ; end of buffer
  99.                 sub     cx,si                   ; calculate string length
  100.                 inc     cx                      ; trailing space
  101.                 mov     dx,si                   ; beginning of string
  102.                 call    printm                  ; print string
  103.                 ret
  104.  
  105. printi          ENDP
  106.  
  107. buffer          db      2 dup (?),' '
  108.  
  109. msg1            db      'list of parent''s interrupt vectors'
  110.  
  111. msg2            db      0Dh,0Ah                 ; also part of message 1
  112.  
  113. _TEXT           ENDS
  114.  
  115.                 END     begin
  116.